﻿using System.Collections.ObjectModel;
using System.Linq;
using ClientCommonWpf;
using Director.DomainModels;

namespace Director.ViewModels
{
	class SecuritiesVM:AbstractToolVM
	{
		public override string Title { get { return "Бумаги"; }}
		
		public override void Init()
		{
			Shares = new ObservableCollection<Security>(DataManager.Instance.SharesByCodes);
			Futures = new ObservableCollection<Security>(DataManager.Instance.Securities.Values.Where(e => e.Sectype == SecurityTypes.FUT));
			Options = new ObservableCollection<Security>();//DataManager.Instance.Securities.Values.Where(e => e.Sectype == SecurityTypes.OPT)
	}

		public override void CandlesUpdated()
		{
			
		}

		public override EToolId ToolId
		{
			get { return EToolId.SECURITIES; }
		}

		public ObservableCollection<Security> Shares { get; private set; }
		public ObservableCollection<Security> Futures { get; private set; }
		public ObservableCollection<Security> Options { get; private set; }

		public RelayCommand ItemDoubleClick{ get; private set; }

		public SecuritiesVM(MainVM mainVM):base(mainVM)
		{
			ItemDoubleClick = new RelayCommand(ExecuteItemDoubleClick);
		}

		private void ExecuteItemDoubleClick(object obj)
		{
			MainVM.OpenDoc(new ChartVM(MainVM, (Security)obj, DataManager.Instance.TimeFrames.Take(3).Last()));
		}
	}
}

